package com.bdqn.day0918.controller;

import com.bdqn.day0918.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @Author:Corday
 * @Date:2021/09/18/10:00
 */
@Controller
@RequestMapping("/user")
public class UserController {
//    打开动态网页
    @RequestMapping("/index")
    public  String goIndex(Map map){
        User user=new User(1086,"小美","女");
        map.put("user",user);
        //map.put("sex","男");
        return "index/index";
    }
    //以下为RPC(remote process call)请求的映射方式
    @RequestMapping("/del")
    //HttpServletRequest
    public String del(@RequestParam("uid") Integer u){//uid
       //执行删除
        System.out.println("用户："+u+"已删除");
      return "index/index";
    }
//通过id号查对象
    @RequestMapping("/findUser")
     public  String find(Integer uid){
        System.out.println("用户为："+uid);
        return "index/index";
     }
// 执行存储记录的操作
    @RequestMapping("/save")
    //自动获取前端传递的参数，并跟实体类对应
    public  String save(User user){
        System.out.println("工号："+user.getUid());
        System.out.println("姓名："+user.getName());
        System.out.println("性别："+user.getSex());
        return "index/index";
    }
}
